package com.ruoyi.web.wapper;

import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.enums.BaseStatusEnum;
import com.ruoyi.common.wapper.BaseControllerWrapper;
import com.ruoyi.source.enums.FlowTypeEnum;
import com.ruoyi.source.enums.SettleFlagEnum;
import org.apache.commons.lang3.ObjectUtils;

import java.util.List;
import java.util.Map;

public class SourceBaseInfoWapper extends BaseControllerWrapper {

    public SourceBaseInfoWapper(Map<String, Object> single) {
        super(single);
    }

    public SourceBaseInfoWapper(List<Map<String, Object>> multi) {
        super(multi);
    }

    @Override
    public void wrapTheMap(Map<String, Object> map) {

        try {

            Integer flowType = (Integer) map.get("flowType");
            if (ObjectUtils.isNotEmpty(flowType)) {
                map.put("flowTypeStr", FlowTypeEnum.getNameByValue(flowType));
            }

            Integer settleFlag = (Integer) map.get("settleFlag");
            if (ObjectUtils.isNotEmpty(settleFlag)) {
                map.put("settleFlagStr", SettleFlagEnum.getNameByValue(settleFlag));
            }

            Integer status = (Integer) map.get("status");
            if (ObjectUtils.isNotEmpty(status)) {
                map.put("statusStr", BaseStatusEnum.getLabelByValue(status));
            }

            Integer pushFlag = (Integer) map.get("pushFlag");
            if (ObjectUtils.isNotEmpty(pushFlag)) {
                map.put("pushFlagStr", ObjectUtil.equal(pushFlag, Integer.valueOf(1))?"推送":"不推送");
            }

        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}
